<?php
/**
 * oscshop 电子商务系统
 *
 * ==========================================================================
 * @link      http://www.oscshop.cn/
 * @copyright Copyright (c) 2015 oscshop.cn. 
 * @license   http://www.oscshop.cn/license.html License
 * ==========================================================================
 *
 * @author    李梓钿
 *
 */
namespace Admin\Widget;
use Think\Controller;
/**
 * 后台菜单
 */
class MenuWidget extends Controller{	

	function menu_show(){
		$u=session('user_auth');
		if($u['username']=='admin'){
			$where['menustatus']=1;
		}else{
			$arr=explode(',',$u['jurisdiction']);
			$p='';
			foreach($arr as $k=>$v){
				$us=explode('$',$v);
				$p.=','.$us[0];
				$us2=explode('#',$us[1]);
				$p.=','.$us2[0];
			}
			$p=trim($p,',');
			$where['menustatus']=1;
			$where['id']=array('in',$p);
		}


		$menu=M('Menu')->where($where)->order('sort_order')->select();

		$tree=list_to_tree($menu,'id','pid','children',0);
		
		$this->admin_menu=$tree;		

		$this->display('Widget:menu');	

	}

	

}

